package name.huzhenbo.java.patterns.strategy;

import java.util.Comparator;

public class StringLengthComparator implements Comparator<String> {
    private StringLengthComparator(){
    }

    public int compare(String s1, String s2) {
        return s1.length() - s2.length();
    }

    public static Comparator getInstance() {
        return SingletonHolder.INSTANCE;
    }

    private static class SingletonHolder {
        public static final Comparator INSTANCE = new StringLengthComparator();
    }
}
